import 'package:eason_nebula/ui/Base/EasonBasePage.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class ToNativePage extends EasonBasePage {
  const ToNativePage({Key? key}) : super(key: key);

  @override
  String get title => 'ToNativePage';

  @override
  State<ToNativePage> createState() => _ToNativePageState();
}

class _ToNativePageState extends BasePageState<ToNativePage> {
  static const _channel = MethodChannel('com.eason.nebula/native');

  @override
  void initState() {
    super.initState();

  }
  // This page is intended to demonstrate navigation to native code.
  // You can implement platform-specific functionality here.
  Future<void> _toNativePage() async {
    try {
      print("Navigating to native page...");
      await _channel.invokeMethod('navigateToNativePage');
      print("Native page navigation successful.");
    } catch (e) {
      print("Error navigating to native page: $e");
    }
  }
  @override
  Widget buildContent(BuildContext context) {
    return Center(
      child: ElevatedButton(
        onPressed: _toNativePage,
        child: Text('跳转到原生页面'),
      ),
    );
  }
}